package cm.studapp;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Button;
import cm.studapp.database.DbManager;
import cm.studapp.helpers.ButtonHelper;
import cm.studapp.helpers.TimeHelper;

public class InitStudApp extends Activity{

	
	
	private TimeHelper timeHelper;
	private ButtonHelper BHelper;
	
	
	Button buttonAddAppointment;
	Button showAgendaToday;
	Button porAhora;
	Button weekView;
	private DbManager db;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     

        
        
        setContentView(R.layout.principal_main);
        InitComponents();
        InitViews();
        //Empezar el servicio, solo 1 vez!
        if(getIntent().getAction()!=null)
        	Services();        
   
    }

    public void onResume(){
    	super.onResume();
    }
    
    private void InitViews() {
		// TODO Auto-generated method stub
    	buttonAddAppointment=(Button)findViewById(R.id.PrinBtn_newSchedule);
    	buttonAddAppointment.setOnClickListener(BHelper);
    	showAgendaToday=(Button)findViewById(R.id.PrinBtn_showToday);
    	showAgendaToday.setOnClickListener(BHelper);
    	if(db.isSemesterSetted()){
    		buttonAddAppointment.setText("Revisa tus actividades");
    	}
		porAhora=(Button)findViewById(R.id.PrinBtn_myStats);
		porAhora.setOnClickListener(BHelper);
		//weekView = (Button)findViewById(R.id.PrinBtn_showSchedule);
	//	weekView.setOnClickListener(BHelper);
	}
    
    public void Services(){
    	Intent dutyChecker = new Intent(this,DutyCheckerService.class);
    	startService(dutyChecker);
    	/*
		Intent intento = new Intent(this, HelloService.class);
		startService(intento); */
	}



	private void InitComponents() {
		// TODO Auto-generated method stub
		db=new DbManager(this);
		timeHelper=new TimeHelper();
		BHelper=new ButtonHelper(this);
	}

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
